//
//  SaliorZhaopingViewController.m
//  shuiyun
//
//  Created by 徐双 on 2017/9/6.
//  Copyright © 2017年 qianyi. All rights reserved.
//

#import "SaliorZhaopingViewController.h"
#import "ReleaseRecodeViewCell.h"
//#import "ReleaseTextViewTableViewCell.h"

@interface SaliorZhaopingViewController ()<UITableViewDelegate,UITableViewDataSource>
{
    NSString * title;
    NSString * z_lian;
    NSString * z_zhiwei;
    NSString * z_tel;
    NSString * z_conter;
  
}

@property (nonatomic, strong) UITableView *tableView;
@end

@implementation SaliorZhaopingViewController

- (void)viewWillAppear:(BOOL)animated{
    
    
    [super viewWillAppear:animated];
    [self.navigationController setNavigationBarHidden:NO animated:NO];
    
}

- (void)viewDidLoad {
    [super viewDidLoad];
    [self creationView];
    [self regeditCell];
    
    // Do any additional setup after loading the view.
}
- (void)creationView {
    [super viewDidLoad];
    
    //[self setTitle:@"发布档案"];
    
    
    
    //初始化tableView
    
    self.tableView = [[UITableView alloc] init];
    self.tableView.frame = CGRectMake(0, 0, DEF_SCREEN_WIDTH, DEF_SCREEN_HEIGHT - 64);
    
    
    self.tableView.tableFooterView = [[UITableView alloc] initWithFrame:CGRectZero];
    
    self.tableView.backgroundColor = [UIColor whiteColor];
    
    self.tableView.delegate = self;
    self.tableView.dataSource = self;
     //self.tableView.estimatedRowHeight = 400;
    self.tableView.separatorStyle = UITableViewCellAccessoryNone;//去掉分割线
    
    
    [self.view addSubview:self.tableView];
    self.view.backgroundColor = [UIColor colorWithRed:245 / 255.0f green:245 / 255.0f blue:245 / 255.0f alpha:1];
    
    UIButton *buttonOut = [[UIButton alloc] init];
    [self.view addSubview:buttonOut];
    [buttonOut mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.view).offset(16);
        make.right.equalTo(self.view).offset(-16);
        make.bottom.equalTo(self.view).offset(-9);
        make.height.offset(40);
        
    }];
    [buttonOut setTitle:@"发布" forState:UIControlStateNormal];
    buttonOut.backgroundColor = getColor(@"3F87F6");
    [buttonOut setTitleColor:getColor(@"FFFFFF") forState:UIControlStateNormal];
    [buttonOut addTarget:self action:@selector(publicLick) forControlEvents:UIControlEventTouchUpInside];
    
}

-(void)publicLick{
    
    NSMutableDictionary *productParams=[[NSMutableDictionary alloc]init];
    NSString *token = [PublicFunction getConfigWithKey:@"token"];
    [productParams setValue:token forKey:@"token"];
    NSString * userid = [PublicFunction getConfigWithKey:@"userid"];
    [productParams setValue:userid forKey:@"userid"];
    [productParams setValue:title forKey:@"title"];
    [productParams setValue:z_lian forKey:@"z_lian"];
    [productParams setValue:z_zhiwei forKey:@"z_zhiwei"];
    [productParams setValue:z_tel forKey:@"z_tel"];
    [productParams setValue:z_conter forKey:@"z_conter"];
    
    
    [[MNetworkHandler sharedInstance]conURL:ReleaseQiuzhi  networkType:NetWorkPOST params:productParams delegate:nil showHUD:NO successBlock:^(id returnData) {
        NSLog(@"%@", returnData);
        NSLog(@"%@", productParams);
        
        if ([[returnData objectForKey:@"code"]intValue]==1) {
            
            
            //NSLog(@"!!!!!!!!!!!!!!!%@",_dataArr);
            
            [PublicFunction showAlert:nil message:@"发布成功" duration:10.0f];
            
            [self.tableView reloadData];
            
            [self.navigationController popViewControllerAnimated:YES];
        }
        
        else {
            
            [PublicFunction showAlert:nil message:[returnData objectForKey:@"msg"] duration:5.0f];
            
        }
        
    } failureBlock:^(NSError *error) {
        
        NSLog(@"%@",error);
        
        [PublicFunction showAlert:nil message:@"没有连接网络" duration:10.0f];
        
    }];

}


-(void)regeditCell{
    
    [self.tableView registerNib:[UINib nibWithNibName:@"ReleaseRecodeViewCell" bundle:nil] forCellReuseIdentifier:@"ReleaseRecodeViewCell"];
    
    //[self.tableView registerNib:[UINib nibWithNibName:@"ReleaseTextViewTableViewCell" bundle:nil] forCellReuseIdentifier:@"ReleaseTextViewTableViewCell"];
    
}

#pragma mark - ---------- Cell的数量 ----------
-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    return 5;
    
    
}

#pragma mark - ---------- 每个Cell的高度 ----------
-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
    
    
    return 50;
    
}

#pragma mark - ---------- 每个Cell的内容 ----------
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    
    ReleaseRecodeViewCell * cell = [tableView dequeueReusableCellWithIdentifier:@"ReleaseRecodeViewCell"];
    
    cell.selectionStyle = UITableViewCellSelectionStyleNone;
    
    if (indexPath.row == 0) {
        
        cell.nameLabel.text = @"标题:";
        cell.textView.placeholder = @"请输入标题";
        cell.textView.text = title;
        
    }else if (indexPath.row == 1){
        
        cell.nameLabel.text = @"联系人:";
        cell.textView.placeholder = @"请输入联系人";
        cell.textView.text = z_lian;
    }else if (indexPath.row == 2){
        
        cell.nameLabel.text = @"职位:";
        cell.textView.placeholder = @"请输入职位";
        cell.textView.text = z_zhiwei;
    }else if (indexPath.row == 3){
        
        cell.nameLabel.text = @"联系方式:";
        cell.textView.placeholder = @"请输入联系方式";
        cell.textView.text = z_tel;
    }else {
        
        cell.nameLabel.text = @"工作经历:";
        cell.textView.placeholder = @"请输入工作经历";
        cell.textView.text = z_conter;
    }
    /*
    else{
        
        ReleaseTextViewTableViewCell * cell = [tableView dequeueReusableCellWithIdentifier:@"ReleaseTextViewTableViewCell"];
        
          cell.selectionStyle = UITableViewCellSelectionStyleNone;        
        cell.contentLabel.text = @"备注:";
        
        return cell;
        
    }
    */
    return cell;
    
}
#pragma mark - ---------- 每个Cell的点击事件 ----------
-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    
}

@end
